<!--
@license
Copyright 2022 The TensorFlow Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<div class="scrolling-page">
  <div class="message">
    <h2 class="warning">WARNING: EXPERIMENTAL FEATURES AHEAD!</h2>
    By enabling these features, you could put the application in an unusable
    state or expose yourself to untested features or potential bugs.
  </div>
  <ng-container *ngIf="hasFlagsSentToServer">
    <div class="message">
      There is a difference between Default - (Enabled/Disabled) and
      (Enabled/Disabled)
    </div>
    <div class="message">
      Only flags with non default values are sent to the backend.
    </div>
  </ng-container>
  <ng-container *ngIf="showFlagsFilter">
    <div class="message">
      Feature Flags are filtered to only show features containing
      "{{showFlagsFilter}}"
    </div>
  </ng-container>
  <table class="feature-flag-table">
    <ng-container *ngFor="let flagStatus of featureFlagStatuses;">
      <tr>
        <td>
          <div>
            {{flagStatus.flag}}
            <sup *ngIf="flagStatus.sendToServerWhenOverridden" class="note-1"
              >1</sup
            >
          </div>
        </td>
        <ng-container
          *ngIf="isEditable(flagStatus); then selectBlock else unsupportedBlock"
        ></ng-container>
        <ng-template #selectBlock>
          <mat-select
            [value]="flagStatus.status"
            (selectionChange)="flagChanged.emit({flag: flagStatus.flag, status: $event.value})"
          >
            <mat-option value="default">
              Default {{formatFlagValue(flagStatus.defaultValue)}}
            </mat-option>
            <mat-option value="enabled">Enabled</mat-option>
            <mat-option value="disabled">Disabled</mat-option>
          </mat-select>
        </ng-template>
        <ng-template #unsupportedBlock>
          <td>Unsupported By UI {{formatFlagValue(flagStatus.value)}}</td>
        </ng-template>
      </tr>
    </ng-container>
  </table>
  <button mat-button (click)="allFlagsReset.emit()">Reset All</button>
  <div *ngIf="hasFlagsSentToServer" class="note-1">
    1. Sent to server when overridden
  </div>
</div>
